'''
* This is the projet for Brtc LlmOps Platform
* @Author Leon-liao <liaosiliang@alltman.com>
* @Description //TODO 
* @File: 4_use_basetool_create_tool.py
* @Time: 2025/11/1
* @All Rights Reserve By Brtc
'''
from typing import Type, Any

from langchain_core.tools import BaseTool
from pydantic import BaseModel, Field


class CaculatorInput(BaseModel):
    a: int = Field(description="第一个数字")
    b: int = Field(description="第二个数字")

class Multiply(BaseTool):
    """乘法计算工具"""
    name:str = "multiply_tool"
    description:str = "将两个数相乘的工具"
    args_schema:Type[BaseModel] = CaculatorInput

    def _run(self, a:int, b:int)->Any:
        return a * b
calculator = Multiply()

print("工具名字:", calculator.name)
print("工具描述:", calculator.description)
print("工具参数:", calculator.args)
print("是否直接返回:", calculator.return_direct)
print("直接调用:",calculator.invoke({"a":2,"b":3}))
